home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / os2 / pine394.zip / bin / pgpsign.cmd < prev    next >
OS/2 REXX Batch file  |  1996-06-25  |  2KB  |  81 lines

  1. /* rexx: pgp send filter for use with PineOS2
  2.  */
  3.  
  4. '@echo off'
  5.  
  6. parse arg infile rest
  7.  
  8. outfile=infile||'.asc'
  9.  
  10. /* You can do one of two things:
  11.  * Comment the next line out, so that pgp will ask for your password,
  12.  * and remove "+batchmode" from the invocation of PGP,
  13.  * OR, you can substitute your PGP secret phrase for the one given
  14.  */
  15.  
  16. call setenv 'PGPPASS', 'top secret'
  17.  
  18. 'pgp -sta +batchmode -o' outfile rest infile
  19. if rc<>0 then
  20.     exit rc
  21.  
  22. p=lastpos('\',infile)
  23. if p > 0 then
  24.     basename=substr(infile,p+1)
  25. else
  26.     basename=infile
  27. 'del' infile
  28. 'ren' outfile basename
  29.  
  30. /* comment the next line out if you prefer to add
  31.    your .signature after the pgp text rather than
  32.    have pine add it beforehand. If you do, make sure
  33.    you set the %SIGNATURE% env var or adjust the code
  34.    below to pick up the correct path!
  35. */
  36.  
  37. exit 0
  38.  
  39. exit addsig(infile)
  40.  
  41. addsig: procedure
  42.     parse arg tmpfile .
  43.     sigfile=getenv('SIGNATURE')
  44.     if sigfile='' then do
  45.         sigfile=getenv('PINEHOME')
  46.         if sigfile='' then
  47.             sigfile=getenv('HOME')
  48.         sigfile=sigfile||'\'||'.signature'
  49.     end
  50.  
  51.     rc=stream(sigfile,'C','open read')
  52.     if rc<>'READY:' then do
  53.         SAY "Warning: no sig" sigfile "("rc")"
  54.         return 0
  55.     end
  56.     rc=stream(tmpfile,'C','open write')
  57.     if rc<>'READY:' then do
  58.         SAY "Can't open" tmpfile ":" rc
  59.         return 1
  60.     end
  61.  
  62.     rc=stream(tmpfile,'C','seek <0')
  63.     rc=lineout(tmpfile,'')
  64.     do while lines(sigfile)
  65.         line=linein(sigfile)
  66.         rc=lineout(tmpfile,line)
  67.     end
  68.  
  69.     rc=stream(tmpfile,'C','close')
  70.     rc=stream(sigfile,'C','close')
  71.     return 0
  72.  
  73. getenv: procedure
  74.     parse arg var .
  75.     return value(var,,'OS2ENVIRONMENT')
  76.  
  77. setenv: procedure
  78.     parse arg var, value
  79.     return value(var,value,'OS2ENVIRONMENT')
  80.  
  81.